package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOPeration{
    @Override
    public void work(BookList booklist) {
        System.out.println("查找图书！");
        System.out.println("请写出您要查找的图书书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int currentSize = booklist.getUsedSize();

        for(int i = 0;i < currentSize;i++){
            Book book = booklist.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("存在这本书，信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有您要找的这本书，书名为："+ name);
    }
}
